package com.sagframe.sagacity.sqltoy.plus.conditions;


import com.sagframe.sagacity.sqltoy.plus.conditions.interfaces.SFunction;
import com.sagframe.sagacity.sqltoy.plus.conditions.segments.MergeSegments;
import com.sagframe.sagacity.sqltoy.plus.conditions.toolkit.LambdaMeta;
import com.sagframe.sagacity.sqltoy.plus.conditions.toolkit.LambdaUtils;
import com.sagframe.sagacity.sqltoy.plus.conditions.toolkit.PropertyNamer;

import java.util.concurrent.atomic.AtomicInteger;

public abstract class AbstractLambdaWrapper<T, Children extends AbstractLambdaWrapper<T, Children>> extends AbstractWrapper<T, SFunction<T, ?>, Children> {

    public AbstractLambdaWrapper(MergeSegments expression, Class<T> entityClass) {
        super(expression, entityClass);
    }

    protected AbstractLambdaWrapper(MergeSegments expression, AtomicInteger paramNameSeq) {
        super(expression, paramNameSeq);
    }

    @Override
    protected String columnToString(SFunction<T, ?> column) {
        LambdaMeta meta = LambdaUtils.extract(column);
        String fieldName = PropertyNamer.methodToProperty(meta.getImplMethodName());
        return fieldName;
    }
}
